package poli.tidia.mobile;

import java.util.List;

import poli.tidia.mobile.model.Topic;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TopicArrayAdapter extends ArrayAdapter<Topic> {

	private final Context context;
	private final List<Topic> values;

	public TopicArrayAdapter(Context context, List<Topic> resources) {
		super(context, R.layout.forum_list_row, resources);
		this.context = context;
		this.values = resources;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.forum_list_row, parent, false);
		TextView textView = (TextView) rowView.findViewById(R.id.label);
		textView.setText(values.get(position).getName());
		
		return rowView;
	}
	
}
